import { homeaction } from "../types/home";
export type usertype = {
  username: string;
  id: number;
  avatar: string;
  birthday: string;
  sex: number;
  introduction: string;
};
export type thumbdobjtype = {
  collectarr: number[];
  commentarr: number[];
  messagearr: number[];
};
export type edimtheme = "dark" | "light";
interface initState {
  thumbdobj: thumbdobjtype; //收藏的文章的id
  user: usertype | {};
  essaypretheme: edimtheme;
}

const initValue: initState = {
  thumbdobj: { collectarr: [], commentarr: [], messagearr: [] },
  user: {},
  essaypretheme: "light",
};

export default function home(state = initValue, action: homeaction) {
  const { type, payload } = action;
  switch (type) {
    case "getthumbarr":
      state.thumbdobj = payload;
      return { ...state };
    case "login":
      state.user = payload;
      return { ...state };
    case "changethemeinessay":
      state.essaypretheme = payload;
      return { ...state };
    default:
      return state;
  }
}

export {};
